<?php

class administradorActions extends sfActions {

       public function executeIndex(sfWebRequest $request)
    {
    }


    public function executePassword(sfWebRequest $request)
    {

    }


     public function executePassword_save(sfWebRequest $request)
    {
        $password=$request->getParameter('password');
        $password1=$request->getParameter('password1');
        $password2=$request->getParameter('password2');

        if($password =="" || $password1 =="" || $password2 ==""){
            $this->getUser()->setFlash('msg','Los datos ingresados no pueden estar vacíos');
            $this->redirect('@admin_password');
        }
        if($password2!=$password1){
            $this->getUser()->setFlash('msg','Repita la contraseña correctamente');
            $this->redirect('@admin_password');
        }

        $configuration = ConfigurationPeer::doSelectOne(new Criteria());

        if($password!=$configuration->getAdminPassword()){
            $this->getUser()->setFlash('msg','La contraseña ingresada es incorrecta');
            $this->redirect('@admin_password');
        }

        $configuration->setAdminPassword($password1);
        $configuration->save();

        $this->getUser()->setFlash('msg','La contraseña fue modificada exitosamente');
        $this->redirect('@admin_index');
    }





  public function executeLogin(sfWebRequest $request)
    {
  
    }


    public function executeLogin_save(sfWebRequest $request)
    {
        $login=$request->getParameter('login');
        $newlogin=$request->getParameter('newlogin');



        if($login==''|| $newlogin==''){
        $this->getUser()->setFlash('msg','El  login no debe ser vacio');
        $this->redirect('@admin_login');
        }

        $configuration = ConfigurationPeer::doSelectOne(new Criteria());
        if($login!=$configuration->getAdminUser()){
            $this->getUser()->setFlash('msg','La contraseña ingresada es incorrecta');
            $this->redirect('@admin_login');
        }

        $configuration->setAdminUser($newlogin);
        $configuration->save();

        $this->getUser()->setFlash('msg','EL login fue modificada exitosamente');
        $this->redirect('@admin_index');
    }




}
?>